﻿package{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.display.Shape;
	import flash.events.MouseEvent;
	import flash.display.SimpleButton;
	import flash.xml.*;
	public class RightOrWrongButton extends Sprite{
		private var _labelR:TextField;
		//private var _labelL:TextField;
		private var _labelW:TextField;
		private var _label2R:TextField;
		//private var _label2L:TextField;
		private var _label2W:TextField;
		private var _labelName:String;
		private var tfR:TextFormat;
		private var tfW:TextFormat;
		private var bg:Sprite;
		private var out:Sprite;
		private var button:SimpleButton;
		private var clicked:Boolean;
		private var style:XMLList;
		public function RightOrWrongButton(stl:XMLList){
			this.style=stl;
			var w:Number=Number(style.width)+2;
			var h:Number=Number(style.height)+2;
			this.clicked=false;
			this.bg=new Sprite();
			this.out=new Sprite();
			tfR = new TextFormat();
			tfR.font=style.rightButton.rightTextFormat.font;
			tfR.color=style.rightButton.rightTextFormat.color;
			tfR.size=style.rightButton.rightTextFormat.size;
		
			tfR.align="center";
			
			
			
			tfW = new TextFormat();
			tfW.font=style.wrongButton.wrongTextFormat.font;
			tfW.color=style.wrongButton.wrongTextFormat.color;
			tfW.size=style.wrongButton.wrongTextFormat.size;
			tfW.align="center";
			this._labelR=new TextField();
			
			_labelR.x=style.x;
			_labelR.y=style.y;
			_labelR.scaleY=1;
			_labelR.scaleX=1;
			_labelR.width=20;
			_labelR.height=h;
			_labelR.selectable=false;
			/*this._labelL=new TextField();
			_labelL.x=20;
			_labelL.y=6;
			_labelL.scaleY=1;
			_labelL.scaleX=1;
			_labelL.width=20;
			_labelL.height=h;
			_labelL.selectable=false;
			*/
			this._labelW=new TextField();
			_labelW.x=style.x;
			_labelW.y=style.y;
			_labelW.scaleY=1;
			_labelW.scaleX=1;
			_labelW.width=20;
			_labelW.height=h;
			_labelW.selectable=false;
			
			//_label.autoSize="right";
			_labelR.text="对";
			_labelR.setTextFormat(tfR);
			//_labelL.text="/";
			//_labelL.setTextFormat(tfL);
			_labelW.text="错";
			_labelW.setTextFormat(tfW);
			
			this._label2R=new TextField();
			
			_label2R.x=10;
			_label2R.y=6;
			_label2R.scaleY=1;
			_label2R.scaleX=1;
			_label2R.width=20;
			_label2R.height=h;
			_label2R.selectable=false;
			/*this._label2L=new TextField();
			_label2L.x=20;
			_label2L.y=6;
			_label2L.scaleY=1;
			_label2L.scaleX=1;
			_label2L.width=20;
			_label2L.height=h;
			_label2L.selectable=false;
			*/
			this._label2W=new TextField();
			_label2W.x=style.x;
			_label2W.y=style.y;
			_label2W.scaleY=1;
			_label2W.scaleX=1;
			_label2W.width=20;
			_label2W.height=h;
			_label2W.selectable=false;
			
			//_label.autoSize="right";
			_label2R.text="对";
			_label2R.setTextFormat(tfR);
			//_label2L.text="/";
			//_label2L.setTextFormat(tfL);
			_label2W.text="错";
			_label2W.setTextFormat(tfW);
			this.bg.graphics.lineStyle(style.rightButton.lineWidth,style.rightButton.lineColor);
			this.bg.graphics.beginFill(style.rightButton.background);
			this.bg.graphics.drawRoundRect(0,0,w,h,15,15);
			this.bg.graphics.endFill();
			this.bg.addChild(_labelR);
			//this.bg.addChild(_labelL);
			//this.bg.addChild(_labelW);
			this.out.graphics.lineStyle(style.wrongButton.lineWidth,style.wrongButton.lineColor);
			this.out.graphics.beginFill(style.wrongButton.background);
			this.out.graphics.drawRoundRect(0,0,w,h,15,15);
			this.out.graphics.endFill();
			//this.out.addChild(_label2R);
			//this.out.addChild(_label2L);
			this.out.addChild(_label2W);
			this.button=new SimpleButton();
			//button.overState=bg;
			//button.downState=out;
			//button.hitTestState=bg;
			//button.upState=out;
			button.useHandCursor=true;
			button.width=w;
			button.height=h;
			button.scaleX=1;
			button.scaleY=1;
			addChild(button);
			}
		public function right(){
			button.overState=bg;
			button.downState=bg;
			button.hitTestState=bg;
			button.upState=bg;
			this.clicked=true;
			
			}
		public function wrong(){
			this.clicked=false;
			button.overState=out;
			button.downState=out;
			button.hitTestState=out;
			button.upState=out;
			
			}
		
		public function getClicked():Boolean{
			
			return this.clicked;
			}

	}



}